import { IsArray, IsNotEmpty, IsNumber, IsOptional, IsString, Length, Matches } from 'class-validator';
import { regExp } from '../../constants/constants';

export class ProductDto {
  @IsNotEmpty({ message: '请输入产品名称' })
  name: string;

  @IsNotEmpty({ message: '请上传产品图片' })
  @IsArray({ message: '请上传产品图片' })
  imageList: string[];

  @IsNotEmpty({ message: '请输入产品价格' })
  //价格，0-1000000，保留两位小数
  @Matches(/^[1-9]\d*$/, { message: '产品价格最多为8位数，允许保留两位小数' })
  basePrice: number;

  @IsNotEmpty({ message: '请输入产品分类' })
  categoryId: number;

  @IsOptional()
  returnGroud7: boolean;

  @IsOptional()
  provideHome: boolean;

  @IsOptional()
  persionPickUp: boolean;

  @IsOptional()
  damagedPackageReturn: boolean;

  @IsOptional()
  lightningRefund: boolean;

  @IsNotEmpty({ message: '请输入产品库存' })
  totalStock: number;

  @IsNotEmpty({ message: '请输入产品概述' })
  productOverview: string;

  @IsOptional()
  provideGlobal: boolean;

  @IsOptional()
  @IsString({ message: '请输入正确产品编码' })
  @Length(0, 8, { message: '产品编码必须是8位字符' })
  productCode: string;

  @IsOptional()
  @IsArray({ message: '请输入产品参数详情' })
  productChoice: string;


}